//index.js
//获取应用实例
var app = getApp()
var _openid = app.getOpenId();
Page({
  data: {
    goods:[],
    loadingMoreHidden:true,
    coupons: [],
    nearLatitude:'',//经度
    nearLongitude:'', //纬度
    goodsDetail:{},
  },
 
  toParkingDetailsTap:function(e){
    var goodsDetailId = e.currentTarget.dataset.id;
     wx.navigateTo({
       url: "/pages/parking-details/index?id="+goodsDetailId 
      })
  },


  scroll: function (e) {
    var that = this,scrollTop=that.data.scrollTop;
    that.setData({
      scrollTop:e.detail.scrollTop
    })
  },
  onLoad: function () {
   
  },

  onShow:function(){
    var that = this;
    wx.setNavigationBarTitle({
      title: "好邻居共享停车"
    })
    that.getGoodsList(0);  
  },

  //获取
  getGoodsList: function (categoryId) {
    wx.showLoading();
    var that = this;
    wx.getLocation({
      type: 'wgs84', //返回可以用于wx.openLocation的经纬度
      success: function (res) {
        var latitude = res.latitude
        var longitude = res.longitude
        wx.request({
          url: app.globalData.domain+app.globalData.subDomain+ '/index/getNearParkingList?',
          method: 'post',
          header: {
            'content-type': 'application/x-www-form-urlencoded'
          },
          data: {
            opeid:_openid,
            latitude: latitude, //返回的纬度
            longitude: longitude, //返回的经度
          },
          success: function (res) {
            wx.hideLoading();
            var goods = [];
            if (res.data.obj.length == 0) {
              that.setData({
                loadingMoreHidden: false,
              });
              return;
            }
            for (var i = 0; i < res.data.obj.length; i++) {
              goods.push(res.data.obj[i]);
            }
            that.setData({
              goods: goods,
            });
            console.log(goods);
          }
        })
      }
      })
  },

 

})
